﻿@using TaskoMask.BuildingBlocks.Contracts.Dtos.Projects


@foreach (var item in Model)
{
    <div class="col-md-3 col-sm-6 col-6 p-2">
        <div class="card bg-success text-white min-height-9rem overflow-hidden card-hover">
            <h6 class="card-header">
                <a class="text-white" href="@($"/project/{item.Id}")">
                    @item.Name
                </a>
                <a @onclick="@(()=>ShowUpdateProjectModal(item.Id))" class="text-warning float-right" >
                    <i class="bi bi-pencil"></i>
                </a>
            </h6>
            <a href="@($"/project/{item.Id}")">
                <div class="card-body text-white">
                    <small>@item.Description</small>
                </div>
            </a>
        </div>
    </div>
}

<div class="col-md-3 col-sm-6 col-6 p-2">
    <a @onclick="@(()=>ShowAddProjectModal())" class="text-center">
        <div class="card text-center text-muted justify-content-center min-height-9rem bg-light-gray card-hover">
            <i class="bi bi-plus">add new project</i>
        </div>
    </a>
</div>




@code {
    [Parameter]
    public IEnumerable<GetProjectDto> Model { get; set; }

    [Parameter]
    public string OrganizationId { get; set; }




    /// <summary>
    ///
    /// </summary>
    private void ShowAddProjectModal()
    {
        var parameters = new ModalParameters();
        parameters.Add(nameof(Pages.Projects.Components.AddProject.OrganizationId), OrganizationId);
        ModalService.Show<Pages.Projects.Components.AddProject>("Add Project", parameters, new ModalOptions { Class="blazored-modal w-75 w-md-50 bg-light-gray"});
    }


    /// <summary>
    ///
    /// </summary>
    private void ShowUpdateProjectModal(string projectId)
    {
        var parameters = new ModalParameters();
        parameters.Add(nameof(Pages.Projects.Components.UpdateProject.Id), projectId);
        ModalService.Show<Pages.Projects.Components.UpdateProject>("Update Project", parameters, new ModalOptions { Class="blazored-modal w-75 w-md-50 bg-light-gray"});
    }
}
